package cn.bbdx.qsh.baking.controller;

import cn.bbdx.qsh.baking.response.JsonResult;
import cn.bbdx.qsh.baking.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/v1/categories/")
public class CategoryController {

    @Autowired
    CategoryService categoryService;

    @GetMapping("{type}/sub")
    public JsonResult sub(@PathVariable Integer type) {

        return JsonResult.ok(categoryService.selectByType(type));
    }

    @GetMapping("{id}/update")
    public JsonResult selectForUpdate(@PathVariable Long id) {

        return JsonResult.ok(categoryService.selectByIdForUpdate(id));
    }

}
